package com.ruiyin.service;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.ruiyin.bean.SysUser;

public class LoginService {

	/**
	 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
	 */
	public Page<Record> paginate(int pageNumber, int pageSize) {
		return  Db.paginate(pageNumber, pageSize, "select a.* ,b.organname", " from sys_user a ,organ  b where a.organcode = b.organcode ");
		//return  SysUser.dao.paginate(pageNumber, pageSize, "select *", " from sys_user");
	}
	
	public SysUser login(SysUser sysUser){
		SysUser su = (SysUser) SysUser.dao.findFirst("select * from sys_user where username=? and role_id=?", sysUser.getUsername(),sysUser.getPassword());
		return su;
	}
	
	
}
